package com.bingo.task;

import com.bingo.service.HisPoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.sql.Date;

/**
 * @author Bingo
 * @version 1.0
 * @description 定时器任务
 * @date 2024/3/23 6:28
 */

@Component
public class ScheduledTasks {

    private HisPoolService hisPoolService;
    @Autowired
    public void setPoolService(HisPoolService hisPoolService) {
        this.hisPoolService = hisPoolService;
    }

    //每天凌晨12.05从cur_pool表记录上一天状态到his_pool表
    @Scheduled(cron = "0 5 0 * * ?")
    public void doTask() {
        System.out.println("日期："+new Date(System.currentTimeMillis())+"开始同步塘表数据！");
        hisPoolService.syncCurPoolToHisPool();
        System.out.println("日期："+new Date(System.currentTimeMillis())+"表数据完成！");
    }
}
